﻿using MediatR;
using RBAC.LuFang.API.Application.Command.GoodsCommand;
using RBAC.LuFang.Domain.Traceability;
using RBAC.LuFang.Domin.Services.TraceabilityService;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;

namespace RBAC.LuFang.API.Application.CommandHandlers.GoodsHandler
{
    //商品添加
    public class GoodsCreateCommandHandler:IRequestHandler<GoodsCreateCommand,int>
    {
        private readonly IGoodsService _goodsService;

        public GoodsCreateCommandHandler(IGoodsService goodsService)
        {
            _goodsService = goodsService;
        }

        public async Task<int> Handle(GoodsCreateCommand request, CancellationToken cancellationToken)
        {
            var goodsModel = new Goods() { goodsId = request.goodsId,goodsName=request.goodsName, goodsProductionBatch=request.goodsProductionBatch, goodsperiod=request.goodsperiod, goodsNumber=request.goodsNumber, goodsQiYe=request.goodsQiYe, goodsImg=request.goodsImg, addName=request.addName, addDate=request.addDate, updName=request.updName, updDate=request.updDate };
            return await _goodsService.AddGoods(goodsModel);
        }
    }
}
